package com.work.xxzl.module.pagemessage;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

import com.work.xxzl.R;
import com.work.xxzl.utils.StatusBarColorUtils;

import java.util.List;

/**
 * author: Aly
 * date :2018/11/15 17:09
 * version:1.0
 * description:聊天页面
 */
public class ChatActivity extends FragmentActivity {
    public static ChatActivity mInstance = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mInstance = this;
        setContentView(R.layout.activity_chat);
        StatusBarColorUtils.setColor(this, R.color.white);
        //修改状态栏为全透明(去掉蒙层)
        StatusBarColorUtils.setTransparencyBar(this);
        //设置状态栏颜色
        StatusBarColorUtils.setStatusBarLightMode(this, StatusBarColorUtils.setStatusBarLightMode(this));
        MyEaseChatFragment chatFragment = new MyEaseChatFragment();
        //传入参数
        chatFragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(R.id.rl_chat, chatFragment).commit();

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    //用于设置友盟统计功能
    @Override
    protected void onResume() {
        super.onResume();

    }


    @Override
    protected void onPause() {
        super.onPause();
    }

    // Activity中 运行申请权限回调传递给 里面的Fragment
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        // 获取到Activity下的Fragment
        List<Fragment> fragments = getSupportFragmentManager().getFragments();
        if (fragments == null) {
            return;
        }
        // 查找在Fragment中onRequestPermissionsResult方法并调用
        for (Fragment fragment : fragments) {
            if (fragment != null) {
                // 这里就会调用我们Fragment中的onRequestPermissionsResult方法
                fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
    }

/*  用到的地方  //发消息
    Intent intent = new Intent(YwhPeopleActivity.this, ChatActivity.class);
                        intent.putExtra(EaseConstant.EXTRA_USER_ID,"fwt123456");
                        intent.putExtra(EaseConstant.EXTRA_CHAT_TYPE,EaseConstant.CHATTYPE_SINGLE);
                        UIUtils.startActivity(intent);*/
}
